
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../css/popup.css"/> 
        <link rel="stylesheet" type="text/css" href="../css/kapiform.css"/> 
        <script type="text/javascript" language="javascript" src="../scripts/jQuery/kapi.js"></script>
        <script type="text/javascript">
        var open_cur = 0;
        $j = jQuery.noConflict();
        $j(document).ready(function(){

        });

    </script>
        <script type="text/javascript">
            $j(document).ready(function(){   
             
                $j('input#dateStart,input#dateStart1, input#dateEnd1').datepicker({ dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '../images/calenda_icon.gif', buttonImageOnly: true }); 
                $j('.passport, .cmnd, .place_of_issue, .place_of_issue1').attr('disabled', true);
                $j('input#dateStart1,input#dateEnd1,input#dateStart').datepicker("disable");
            
                if($j('.checkCmnd').is(':checked')){
                    $j('.cmnd, .place_of_issue').attr('disabled', false); 
                    $j(".alert2").text("");
                    $j('input#dateStart').datepicker("enable");
                }
                $j(".checkCmnd").live("click",function(){
              
                    if($j('.checkCmnd').is(':checked')){
                        $j('.cmnd, .place_of_issue').attr('disabled', false);
                        $j('.sumbitEmp').attr('disabled', false);
                        //$j(".alert2").text("");
                        $j('input#dateStart').datepicker("enable");
                    }else{
                        $j('.cmnd, .place_of_issue').attr('disabled', true); 
                        $j('.sumbitEmp').attr('disabled', true);
                        $j('input#dateStart').datepicker("disable");
                    }
                       
                }); 
                if($j('.checkPassport').is(':checked')){
                    $j('.passport, .place_of_issue1').attr('disabled', false); 
                    $j('.sumbitEmp').attr('disabled', false);
                    $j('input#dateStart1,input#dateEnd1').datepicker("enable");
                }
                $j(".checkPassport").live("click",function(){
              
                    if($j('.checkPassport').is(':checked')){
                        $j('.passport, .place_of_issue1').attr('disabled', false); 
                        $j('.sumbitEmp').attr('disabled', false);
                        $j('input#dateStart1,input#dateEnd1').datepicker("enable");
                    }else{
                        $j('.passport, .place_of_issue1').attr('disabled', true); 
                        $j('.sumbitEmp').attr('disabled', true);
                        $j('input#dateStart1,input#dateEnd1').datepicker("disable");
                    }
                       
                }); 
                
                 $j(".cmnd").bind('blur', function(){
                cmnd = $j(this).val();
              
                if(cmnd==''){
                    
                }else{
                    $j.post('actionCheckExist.jsp?action=checkExistcmnd&cmnd='+cmnd,function(data){                  
                        if(data!=0){                          
                            $j('.mesage').text('CMND đã có người sử dụng(không cập nhật dữ liệu)!!');
                        }else{                         
                            $j('.mesage').text('Có thể sử dụng CMND này');
                        }
                    }); 
                }                         
            });
               
                $j("#dateStart1").live("change",function(){
                    var DateToValue = process($j("#dateStart1").val());
                    var DateFromValue = process($j("#dateEnd1").val());
                    if(DateFromValue !=null){                        
                        if (DateToValue <= DateFromValue) {
                            $j(".alert").text("");
                            $j('.sumbitEmp').attr('disabled', false);
                   
                        }else{
                            $j('.sumbitEmp').attr('disabled', true);
                            $j(".alert").text("Chú ý: Ngày hết hạn phải lớn hơn ngày cấp");
                            $j("#dateEnd1").text("");
                        }
                        
                    }
                    $j( "#dateStart1" ).datepicker({ dateFormat: "dd/mm/yy" });
                });
                $j("#dateEnd1").live("change",function(){
                    var DateToValue = process($j("#dateStart1").val());
                    var DateFromValue = process($j("#dateEnd1").val());
                    
                    if (DateToValue <= DateFromValue) {
                        $j(".alert").text("");
                        $j('.sumbitEmp').attr('disabled', false);
                   
                    }else{
                        $j('.sumbitEmp').attr('disabled', true);
                        $j(".alert").text("Chú ý: Ngày hết hạn phải lớn hơn ngày cấp");
                        $j("#dateEnd1").text("");
                    }
                    $j( "#dateEnd1" ).datepicker({ dateFormat: "dd/mm/yy" });
                });
                var b = location.pathname;
                $j("input[id$='message']").val(b);
            
             
            });
            function process(date){
                var parts = date.split("/");
                var date = new Date(parts[1] + "/" + parts[0] + "/" + parts[2]);
                return date.getTime();
            }
        </script>
    </head>
    <f:view>
        <f:loadBundle basename="#{environmentSession.localizationSource}" var="locale"/>
        <body>
            <a4j:form id="form-input-passport" >
                <div class="popup-content">
                    <div class="main_content">
                        <div class="form_item_content labe_short" style="display: block;">
                            <div style="float:left; width:50%;">
                                <div class="fields_input">
                                    <label class="lbl_checkbox"><h:outputText value="#{locale.identification}"/>*:</label>
                                    <h:selectBooleanCheckbox value="#{n350Controller.nn355c}"  styleClass="checkCmnd" />

                                </div>
                                <div class="fields_input">
                                    <label><h:outputText value="#{locale.number}"/>*:</label>
                                    <h:inputText value="#{n350Controller.nv351c}" id="cmnd" styleClass="cmnd required maxlength number" lang="16">

                                    </h:inputText>

                                </div>
                                <div class="fields_input fixdate">
                                    <label><h:outputText value="#{locale.date_of_issue}"/>:</label>
                                    <input value="<h:outputText value="#{n350Controller.nd352c}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateStart" name="dateStart" class="input_fields date" />


                                    </div>
                                    <div class="fields_input">
                                        <label><h:outputText value="#{locale.place_of_issue}"/>:</label>
                                    <h:inputText value="#{n350Controller.nv354c}" styleClass="place_of_issue" />
                                </div>
                            </div>
                            <div style="float:left; width:49%; border-left: 1px solid #D4D7D8;">
                                <div class="fields_input">
                                    <label class="lbl_checkbox"><h:outputText value="#{locale.passport}"/>*:</label>
                                    <h:selectBooleanCheckbox value="#{n350Controller.nn355p}"  styleClass="checkPassport"/>

                                </div>
                                <div class="fields_input">
                                    <label><h:outputText value="#{locale.number}"/>*:</label>
                                    <h:inputText value="#{n350Controller.nv351p}" id="passport"  styleClass="passport required " >

                                    </h:inputText>

                                </div>
                                <div class="fields_input fixdate">
                                    <label><h:outputText value="#{locale.date_of_issue}"/>:</label>
                                    <input  value="<h:outputText value="#{n350Controller.nd352p}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateStart1" name="dateStart1" class="dateStart1 input_fields date"  />


                                    </div>
                                    <div class="fields_input fixdate">
                                        <label><h:outputText value="#{locale.closing_date}"/>:</label>
                                    <input value="<h:outputText value="#{n350Controller.nd353p}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateEnd1" name="dateEnd1" class="dateEnd1 input_fields date" />

                                    </div>
                                    <div class="fields_input">
                                        <label><h:outputText value="#{locale.place_of_issue}"/>:</label>
                                    <h:inputText value="#{n350Controller.nv354p}" styleClass="place_of_issue1" />
                                </div>

                            </div>


                        </div>

                    </div>

                </div>
                <div class="popup-footer">
                    <h:outputText value="#{n350Controller.messageform}" id="mesage" styleClass="mesage"/>                   
                    <a4j:commandButton id="sumbitEmp" onclick="showPleaseWait();$j('.mesage').text('');" oncomplete="hidePleaseWait();" action="#{n350Controller.saveN350}" value="#{locale.save}" styleClass="buttonsave sumbitEmp" reRender="mesage">
                    </a4j:commandButton>                    
                    <h:inputHidden value="#{n350Controller.fn100}" id="fn100"/>
                    <h:inputHidden value="#{n350Controller.pn350}" id="pn350"/>
                    <h:inputHidden value="#{n350Controller.pn350c}" id="pn350c"/>
                    <h:inputHidden value="#{n350Controller.pn350p}" id="pn350p"/>


                </div>
            </a4j:form>
        </body>
    </f:view>

</html>
